package com.jh3502.vivo.function.main;

import android.support.annotation.NonNull;

import com.jh3502.vivo.base.BaseCallback;
import com.jh3502.vivo.base.BaseJson;
import com.jh3502.vivo.base.BasePresenter;
import com.jh3502.vivo.base.BaseView;
import com.jh3502.vivo.utils.Utils;

/**
 * @author harisucici
 * @date 2017/6/19
 */

public class MainPresenter extends BasePresenter<MainPresenter.MainView> {
    MainModel mMainModel;

    MainView mMainView;

    public void setMainView(MainView mMainView) {
        this.mMainView = mMainView;
    }

    public void toFindTdNum() {
        mMainView.showLoadingDialog();
        if (mMainModel == null) {
            mMainModel = new MainModel(mMainView.getActContext());
        }

        mMainModel.findTdNum(new BaseCallback(mMainView) {
            @Override
            public void responseSuccess(@NonNull BaseJson baseJson) {
                int num = (int) Utils.getInstance().jso2map(baseJson.getObj().toString()).get("num");
                mMainView.findTdNumSuccess(num);
            }
        });
    }


    @Override
    public void cancelCall() {

    }

    public interface MainView extends BaseView {
        void findTdNumSuccess(int num);
    }
}
